<?php

namespace app\index\model;


use app\admin\common\ModelBase;
use service\JsonService;
use think\Exception;

class UserLog extends ModelBase
{
    // 设置当前模型对应的完整数据表名称
    protected $table = 'so_user_log';



    /**
     * @param array $param
     * @param string $order
     * @author: hhygyl <hhygyl520@qq.com>
     * @name: GetAdminLogDataPage
     * @describe:获取分页数据
     */
    public function GetUserLogDataPage($param = [], $order = "id desc")
    {
        $where = [];
        if(!empty($param)) {
            //添加条件

            //搜索条件
            if(!empty($param['admin_name'])) {
                $where['admin_name|describe'] = ['like', "%".$param['admin_name']."%"];
            }
            if(!empty($param['type'])){
                $where['type']=$param['type'];
            }
        }

        try {
            $data = $this->where($where)->order($order)->page(PAGE)->limit(PERPAGE)->select()->toArray();

            $count=$this->where($where)->count("id");
           // $count = count($data);

        } catch (Exception $exception) {

            return JsonService::fail($exception->getMessage());
        }
        return JsonService::result(0, "", $data, $count);

    }



}